 package server.events;

 import client.MapleCharacter;
import server.Timer;
import tools.MaplePacketCreator;

import java.util.LinkedList;
import java.util.List;






 public class MapleCoconut
   extends MapleEvent
 {
/*  12 */   private final List<MapleCoconuts> coconuts = new LinkedList<>();
/*  13 */   private final int[] coconutscore = new int[2];
/*  14 */   private int countBombing = 0;
/*  15 */   private int countFalling = 0;
/*  16 */   private int countStopped = 0;

   public MapleCoconut(int channel, MapleEventType type) {
/*  19 */     super(channel, type);
   }



   public void finished(MapleCharacter chr) {}


   public void reset() {
/*  28 */     super.reset();
/*  29 */     resetCoconutScore();
   }


   public void unreset() {
/*  34 */     super.unreset();
/*  35 */     resetCoconutScore();
/*  36 */     setHittable(false);
   }


   public void onMapLoad(MapleCharacter chr) {
/*  41 */     super.onMapLoad(chr);
/*  42 */     chr.send(MaplePacketCreator.coconutScore(getCoconutScore()));
   }

   public MapleCoconuts getCoconut(int id) {
/*  46 */     if (id >= this.coconuts.size()) {
/*  47 */       return null;
     }
/*  49 */     return this.coconuts.get(id);
   }

   public List<MapleCoconuts> getAllCoconuts() {
/*  53 */     return this.coconuts;
   }

   public void setHittable(boolean hittable) {
/*  57 */     for (MapleCoconuts nut : this.coconuts) {
/*  58 */       nut.setHittable(hittable);
     }
   }

   public int getBombings() {
/*  63 */     return this.countBombing;
   }

   public void bombCoconut() {
/*  67 */     this.countBombing--;
   }

   public int getFalling() {
/*  71 */     return this.countFalling;
   }

   public void fallCoconut() {
/*  75 */     this.countFalling--;
   }

   public int getStopped() {
/*  79 */     return this.countStopped;
   }

   public void stopCoconut() {
/*  83 */     this.countStopped--;
   }

   public int[] getCoconutScore() {
/*  87 */     return this.coconutscore;
   }

   public int getMapleScore() {
/*  91 */     return this.coconutscore[0];
   }

   public int getStoryScore() {
/*  95 */     return this.coconutscore[1];
   }

   public void addMapleScore() {
/*  99 */     this.coconutscore[0] = this.coconutscore[0] + 1;
   }

   public void addStoryScore() {
/* 103 */     this.coconutscore[1] = this.coconutscore[1] + 1;
   }

   public void resetCoconutScore() {
/* 107 */     this.coconutscore[0] = 0;
/* 108 */     this.coconutscore[1] = 0;
/* 109 */     this.countBombing = 80;
/* 110 */     this.countFalling = 401;
/* 111 */     this.countStopped = 20;
/* 112 */     this.coconuts.clear();
/* 113 */     for (int i = 0; i < 506; i++) {
/* 114 */       this.coconuts.add(new MapleCoconuts());
     }
   }


   public void startEvent() {
/* 120 */     reset();
/* 121 */     setHittable(true);
/* 122 */     getMap(0).broadcastMessage(MaplePacketCreator.serverNotice(5, "The event has started!!"));
/* 123 */     getMap(0).broadcastMessage(MaplePacketCreator.hitCoconut(true, 0, 0));
/* 124 */     getMap(0).broadcastMessage(MaplePacketCreator.getClock(300));

/* 126 */     Timer.EventTimer.getInstance().schedule(() -> { if (getMapleScore() == getStoryScore()) { bonusTime(); } else { for (MapleCharacter chr : getMap(0).getCharactersThreadsafe()) { if (chr.getTeam() == ((getMapleScore() > getStoryScore()) ? 0 : 1)) { chr.send(MaplePacketCreator.showEffect("event/coconut/victory")); chr.send(MaplePacketCreator.playSound("Coconut/Victory")); continue; }  chr.send(MaplePacketCreator.showEffect("event/coconut/lose")); chr.send(MaplePacketCreator.playSound("Coconut/Failed")); }  warpOut(); }  },300000L);
   }
















   public void bonusTime() {
/* 145 */     getMap(0).broadcastMessage(MaplePacketCreator.getClock(60));
/* 146 */     Timer.EventTimer.getInstance().schedule(() -> { if (getMapleScore() == getStoryScore()) { for (MapleCharacter chr : getMap(0).getCharactersThreadsafe()) { chr.send(MaplePacketCreator.showEffect("event/coconut/lose")); chr.send(MaplePacketCreator.playSound("Coconut/Failed")); }  warpOut(); } else { for (MapleCharacter chr : getMap(0).getCharactersThreadsafe()) { if (chr.getTeam() == ((getMapleScore() > getStoryScore()) ? 0 : 1)) { chr.send(MaplePacketCreator.showEffect("event/coconut/victory")); chr.send(MaplePacketCreator.playSound("Coconut/Victory")); continue; }  chr.send(MaplePacketCreator.showEffect("event/coconut/lose")); chr.send(MaplePacketCreator.playSound("Coconut/Failed")); }  warpOut(); }  },60000L);
   }





















   public void warpOut() {
/* 170 */     setHittable(false);
/* 171 */     Timer.EventTimer.getInstance().schedule(() -> { for (MapleCharacter chr : getMap(0).getCharactersThreadsafe()) { if ((getMapleScore() > getStoryScore() && chr.getTeam() == 0) || (getStoryScore() > getMapleScore() && chr.getTeam() == 1)) givePrize(chr);  warpBack(chr); }  unreset(); },10000L);
   }









   public static class MapleCoconuts
   {
/* 184 */     private int hits = 0;
     private boolean hittable = false;
     private boolean stopped = false;
/* 187 */     private long hittime = System.currentTimeMillis();

     public void hit() {
/* 190 */       this.hittime = System.currentTimeMillis() + 1000L;
/* 191 */       this.hits++;
     }

     public int getHits() {
/* 195 */       return this.hits;
     }

     public void resetHits() {
/* 199 */       this.hits = 0;
     }

     public boolean isHittable() {
/* 203 */       return this.hittable;
     }

     public void setHittable(boolean hittable) {
/* 207 */       this.hittable = hittable;
     }

     public boolean isStopped() {
/* 211 */       return this.stopped;
     }

     public void setStopped(boolean stopped) {
/* 215 */       this.stopped = stopped;
     }

     public long getHitTime() {
/* 219 */       return this.hittime;
     }
   }
 }


/* Location:              C:\PGX\Server.jar!\server\events\MapleCoconut.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */